

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function check_input_data()
{

var retvalue = true;

var strDocNr = document.forms[0].searchform_doc_nr.value ;
strDocNr = strDocNr.trim(strDocNr);

if(strDocNr.length != 10){

     return false;
   }

var Last8 = strDocNr.substring(2,10);

if(Last8.length != 8){

     return false;
   }
   
var IsInteger= /^-?\d+$/.test(Last8);

if (IsInteger)
 { return true;} 
 else
 { return false ;} 
 
}


function post_data_to_server()
{

var check_ok = check_input_data();

if (check_ok)
 {
  document.forms[0].submit(); 
 }
 else
 {
 alert('Dokumendi numbri formaat vale!');
 }
}

